from selenium.webdriver.common.by import By

from TestFunction.FormLogin import FormLogin
from common.Utils import FormDriver


class FormListTest:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://127.0.0.1:9580/index.html"
        self.driver = FormDriver.driver
        self.driver.get(self.url)
    def FormListWebTest(self):

        # 标题存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > h1 > a > img")
         #首页按钮
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a")
        #功能按钮表列
        testList = self.driver.find_elements(By.CSS_SELECTOR,"#topBoardList")
        for i in testList:
            print(i.text)
         #搜索框
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input")
         #夜间模式按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark > svg")
         #消息按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a > svg")
         #用户名
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_nickname")
         #用户类型按钮
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_name_sub")
         #发布贴按钮
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post")
    def FormListUsDark(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark > svg")
        FormDriver.DribverScreeShot()
    def FormListUsMs(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a > svg").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_offcanvasEnd > div.offcanvas-header")
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_offcanvasEnd > div.offcanvas-header > button").click()
    def FormLisUsUname(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.dropdown").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_settings")
        #查看用户类型
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_name_sub")
    def FormLisUsPublish(self):
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post")

    def FormListUse(self):
        self.FormListUsDark()
        self.FormListUsMs()
        self.FormLisUsUname()
        self.FormLisUsPublish()




